package com.samphanie.auiu.auth.validation.code.captcha;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.samphanie.auiu.mbg.model.BaseEntity;
import lombok.*;
import lombok.experimental.SuperBuilder;

import java.io.Serializable;
import java.util.Date;

/**
 * 验证码
 *
 * @author ZSY
 * @email 1451691457@qq.com
 */
@Data
@With
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@TableName("sys_captcha")
@EqualsAndHashCode(callSuper = true)
public class Captcha extends BaseEntity implements Serializable {
    private static final long serialVersionUID = 5673412253031449576L;


    private String uuid;
    /**
     * 验证码
     */
    private String code;
    /**
     * 过期时间
     */
    private Date expireTime;

    @JsonIgnore
    public boolean isExpired() {
        return new Date().after(expireTime);
    }
    @JsonIgnore
    public Date getExpiredTime(long expireIn) {
        return Date.from(new Date().toInstant().plusSeconds(expireIn));
    }
}
